<?php

namespace App\Models\User\Repositories;

use App\Models\User\User;
use Illuminate\Support\Facades\Cache;

class CacheUser
{
    public function cache(?User $user): void
    {
        $user
        && !Cache::get(User::cacheKey($user->getUserId()))
        && Cache::put(User::cacheKey($user->getUserId()), $user, config('trip.ttl.day'));
    }

    public function forget(?string $user_id): void
    {
        $user_id && Cache::forget(User::cacheKey($user_id));
    }
}